package com.fox.contrller;

import com.fox.domain.ResponseResult;
import com.fox.domain.dto.EditTagDto;
import com.fox.domain.dto.TagListDto;
import com.fox.domain.entity.Tag;
import com.fox.domain.vo.PageVo;
import com.fox.domain.vo.TagVo;
import com.fox.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/content/tag")
public class TagController {
    @Autowired
    private TagService tagService;

    @GetMapping("/list")
    public ResponseResult<PageVo> list(Integer pageNum, Integer pageSize, TagListDto tagListDto){
        return tagService.pageTagList(pageNum,pageSize,tagListDto);
    }

    @PostMapping
    public ResponseResult addTag(@RequestBody Tag tag) {
        return tagService.addTag(tag);
    }

    @DeleteMapping("/{id}")
    public ResponseResult deleteTag(@PathVariable Long id) {
        return tagService.deleteTag(id);
    }

    @GetMapping("/{id}")
    public ResponseResult getTagById(@PathVariable Long id) {
        return tagService.getTagById(id);
    }
    @PutMapping
    public ResponseResult editTag(@RequestBody EditTagDto editTagDto) {
        return tagService.editTag(editTagDto);
    }

    @GetMapping("/listAllTag")
    public ResponseResult listAllTag() {
        List<TagVo> list = tagService.listAllTag();
        return ResponseResult.okResult(list);
    }
}
